#include "Control.h"


bool Control::OnInit()
{
    m_frame = new ControlFrame;
    if( !m_frame ){
        goto fail;
    }

    m_model = new Model;
    if( !m_model ){
        goto fail;
    }

    m_model_draw = new ModelDraw;
    if( !m_model_draw ){
        goto fail;
    }
    m_model_draw->setModel( m_model );
    m_model_draw->setup();

    m_frame->setModel( m_model );
    m_frame->setModelDraw( m_model_draw );

    if( m_frame->setup() != true ){
        goto fail;
    }

    return true;

fail:
    if(m_frame){
        m_frame->teardown();
        delete m_frame;
    }
    if( m_model ){
        m_model->teardown();
        delete m_model;
    }
    return false;
}